var _n63;
var cc__extends = __extends;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $miniGameApiBase = require("miniGameApiBase");
var a = window.tt;
var def_huaWeiApi = function (t) {
  function _ctor() {
    var e = null !== t && t.apply(this, arguments) || this;
    e.m_AppId = "";
    e.m_Secret = "";
    e.m_VideoAdIdIndex = 0;
    e.m_VideoAdIdList = [];
    e.m_BannerAdIdIndex = 0;
    e.m_BannerAdId = [];
    e.m_InsertAdIdIndex = 0;
    e.m_InsertAdId = [];
    e.m_videoAd = undefined;
    e.m_BannerAd = undefined;
    return e;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.validAppId = function () {
    console.log("oppo-api-validAppId");
  };
  _ctor.prototype.ready = function () {
    console.log("huaWei-api-ready");
  };
  _ctor.prototype.getUserInfo = function (t) {
    a.getUserInfo(t);
  };
  _ctor.prototype.showToast = function (t) {
    a.showToast(t);
  };
  _ctor.prototype.showLoading = function (t) {
    a.showLoading(t);
  };
  _ctor.prototype.hideLoading = function () {
    a.hideLoading();
  };
  _ctor.prototype.showModal = function (t) {
    a.showModal(t);
  };
  _ctor.prototype.authorize = function (t) {
    t.success && t.success();
  };
  _ctor.prototype.login = function (t) {
    a.login(t);
  };
  _ctor.prototype.getVideoAdId = function () {
    var t = this.m_VideoAdIdList[this.m_VideoAdIdIndex];
    this.m_VideoAdIdIndex++;
    this.m_VideoAdIdIndex >= this.m_VideoAdIdList.length && (this.m_VideoAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.loadAndShowVideoAd = function (t, e, o, n) {
    var i = this;
    this.showLoading({
      title: "请求中",
      mask: true
    });
    var r = this.getVideoAdId();
    console.log("tt 视频广告", r, n);
    var s = a.createRewardedVideoAd({
      adUnitId: r
    });
    var c = function c(n) {
      s.offClose(c);
      console.log("tt 视频广告关闭", n);
      if (n && n.isEnded) {
        t();
      } else {
        e("视频中途退出");
      }
      o && o();
    };
    console.log("展示一次");
    s.show().then(function () {
      i.hideLoading();
      s.onClose(c);
    }).catch(function () {
      console.log("重试一次");
      s.load().then(function () {
        s.show().then(function () {
          i.hideLoading();
          s.onClose(c);
        }).catch(function () {
          e && e("视频展示异常");
          o && o();
        });
      }).catch(function () {
        e && e("视频拉取异常02");
        o && o();
      });
    });
  };
  _ctor.prototype.getInsertAdId = function () {
    var t = this.m_InsertAdId[this.m_InsertAdIdIndex];
    this.m_InsertAdIdIndex++;
    this.m_InsertAdIdIndex >= this.m_InsertAdId.length && (this.m_InsertAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.showInsertAd = function (t, e) {
    console.log("加抖音 插屏 广告");
    var o = this.getInsertAdId();
    var n = a.createInterstitialAd({
      adUnitId: o
    });
    n.load();
    n.onLoad(function () {
      console.warn("插屏广告 加载完成");
      n.show().catch(function (t) {
        console.warn("插屏广告 显示失败 :" + JSON.stringify(t));
        n.destroy();
        n = null;
        e && e();
      });
    });
    n.onError(function (t) {
      console.warn("插屏广告 加载失败" + JSON.stringify(t));
      n.destroy();
      n = null;
      e && e();
    });
    n.onClose(function () {
      console.warn("插屏广告 关闭");
      if (null != n) {
        n.destroy();
        n = null;
      }
      t && t();
    });
  };
  _ctor.prototype.getBannerAdId = function () {
    var t = this.m_BannerAdId[this.m_BannerAdIdIndex];
    this.m_BannerAdIdIndex++;
    this.m_BannerAdIdIndex >= this.m_BannerAdId.length && (this.m_BannerAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.showBannerAD = function () {};
  _ctor.prototype.hideBanner = function () {};
  _ctor.prototype.recordedGameScreenStart = function (t, e) {
    console.log("huaWei-api-recordedGameScreenStart");
    e && e(null);
  };
  _ctor.prototype.recordedGameScreenStop = function () {
    console.log("huaWei-api-recordedGameScreenStop");
    return true;
  };
  _ctor.prototype.shareRecordedGameScreen = function (t) {
    console.log("huaWei-api-shareRecordedGameScreen");
    t && t();
  };
  _ctor.prototype.isHaveRecordedGameScreen = function () {
    return true;
  };
  return _ctor;
}($miniGameApiBase.MiniGameApiBase);
exports.default = def_huaWeiApi;